<template>
    <store-default v-if="isDataDefault" :introduce-url="introduce_url" />
    <div v-else class="store_message_list_container">
        <ZWSearch row-num="3" :option="searchOption" @search="search" @reset="reset" />
        <ZWTable
            ref="storeTableRef"
            class="table-box"
            tab-h="initial"
            :option="tableOption"
            :fetch-params="state.searchParams"
            :fetch-api="fetchApi()">
            <template #headerOperate>
                <el-button type="primary" @click="addStore">添加店铺</el-button>
            </template>
        </ZWTable>
    </div>

    <Dialog :app-dialog="appDialogEditStore">
        <el-form ref="editStoreFormRef" :model="editStoreForm" :rules="editStoreFormRules" label-width="auto">
            <el-form-item label="店铺名称" prop="name">
                <el-input v-model="editStoreForm.name" placeholder="请输入店铺名称" />
            </el-form-item>
        </el-form>
    </Dialog>

    <Dialog :app-dialog="appDialogDeleteStore">
        <div class="tips">{{ tips }}</div>
    </Dialog>

    <select-store-type-dialog v-model="isShowSelectStore" />

    <el-dialog v-model="changePackage" title="企业专属顾问" width="25%" center>
        <div class="qwQrCode" style="text-align: center">
            <img src="https://static.scrm.keyid.cn/assets/images/global/service.png" alt="" />
        </div>
        <p style="text-align: center">扫码添加企微顾问，开通使用！</p>
    </el-dialog>
    <openMemberPass ref="openMemberPassRef" @submit="onMemberPassSubmit" />

    <!-- 调整会员通弹框 of start -->
    <el-dialog v-model="adjustDialog" title="调整会员通设置" width="30%">
        <el-radio-group v-model="member_rule_follow" class="ml-4">
            <el-radio v-for="item in memberRules" :key="item.id" :disabled="item.status != 1" :label="item.id">
                {{ item.point_rule_name }}
            </el-radio>
        </el-radio-group>
        <div class="adjust_dialog_content">
            注意：调整设置时，请检查
            <span @click="handleOpenIntegral">积分设置</span> 以及有赞平台的积分规则设置，避免订单重复计算！
        </div>
        <template #footer>
            <span class="dialog-footer">
                <el-button @click="adjustDialog = false">取消</el-button>
                <el-button type="primary" @click="handleConfirmAdjustMemberPass"> 确定 </el-button>
            </span>
        </template>
    </el-dialog>
    <!-- 调整会员通弹框 of end -->
</template>

<script lang="tsx">
import { defineComponent } from 'vue';
// 定义name专用script标签
// eslint-disable-next-line vue/component-definition-name-casing
export default defineComponent({ name: 'STORE_MANAGE_LIST' });
</script>

<script setup lang="tsx">
import { reactive, ref, onMounted, computed, onActivated } from 'vue';
import { ElMessage, ElButton, ElPopper } from 'element-plus';
import type { FormInstance, FormRules } from 'element-plus';
import Dialog from '@/components/Dialog.vue';
import {
    getStoreList,
    getStoreSourceList,
    updateStoreState,
    editStore,
    testStore,
    deleteStore,
    shopDateInit,
    getChannelByShopId
} from '@/api/ecommerce/storeManage';
import { getBehaviorSync, getStoreSync } from '@/api/ecommerce/userManage';
import ZWSearch from '@/components/zw/search-form/SearchForm';
import ZWTable from '@/components/zw/table/Table';
import selectStoreTypeDialog from './components/selectStoreTypeDialog.vue';
import storeDefault from '../../components/storeDefault.vue';
import tableHeaderTooltip from '../../components/tableHeaderTooltip.vue';
import openMemberPass from './components/openMemberPass/openMemberPass.vue';

import lodash from 'lodash';
import { deepCopy } from '@/utils/helper';
import router from '@/router';
import { PROMOTION_ACTIVITY } from '@/const/ecommerce';

import { getCreateList } from '@/api/common';

import { memberSwitchChannel } from '@/api/member/memberList';
import { ShowTaskMessage } from '@/hooks/TaskMessageHooks';
import { parabolaAnimation } from '@/utils/parabola';

const storeTableRef = ref<HTMLElement | null>(null);
const editStoreFormRef = ref<FormInstance>();
const tips = ref<string>('删除后，该店铺数据将不能同步，店铺关联的数据也会清除，您确定要删除该店铺吗？');
const isShowSelectStore = ref<boolean>(false);
const isDataDefault = ref<boolean>(false);
const introduce_url = ref<string>('');
const changePackage = ref(false);
const sync_type_tips = ref<any[]>([
    {
        id: 1,
        text: '实时同步：店铺交易及行为数据，初始垃取后，实时同步店铺数据至平台'
    },
    {
        id: 2,
        text: '默认同步：从店铺授权起，默认先同步近90天的历史订单数据后再进行实时同步，耗时约2-3天'
    }
]);

type defaultParamsType = {
    source: number | string;
    shop_info: string;
};

const requestFlag = ref<boolean>(false);
const currentParams = ref<any>(null);

const defaultParams: defaultParamsType = {
    source: 0, //  0 全部  1 客易达   2 有赞   3 淘宝   4 自营   5 线下门店   6 天猫   7 抖店   8 京东
    shop_info: ''
};
type stateType = {
    searchParams: any;
    deleteId: number | string;
    searchHeight: string;
};
const state = reactive<stateType>({
    searchParams: lodash.cloneDeep(defaultParams),
    deleteId: '',
    searchHeight: '112px'
});

type editStoreFormType = {
    shop_id?: string | number;
    name: string;
    source?: string | number;
};
const editStoreForm = reactive<editStoreFormType>({
    shop_id: '',
    name: '',
    source: ''
});
const editStoreFormRules = reactive<FormRules>({
    name: [{ required: true, message: '请输入店铺名称', trigger: 'blur' }]
});

// 按钮是否显示
const createIsRender = (state: any[]) => {
    return ({ row }: any) => state.includes(row.state_name);
};
const createIsRenderFunc = (state: any[]) => {
    return ({ row }: any) => !state.includes(row.state_name);
};
// 更改店铺状态
const onChangeState = (row: any) => {
    const { id: shop_id } = row;
    const state = row.state == 1 ? 3 : 1;
    const params = { shop_id, state };
    updateStoreState(params).then(() => {
        ElMessage.success(`${row.state == 1 ? '暂停成功' : '运行成功'}`);
        storeTableRef.value?.reload?.();
    });
};
const searchOption = computed(() => {
    return [
        {
            label: '店铺类型',
            name: 'source',
            value: '',
            type: 'select',
            placeholder: '请选择店铺类型',
            fetchOptionApi: () => {
                return new Promise(resolve => {
                    getStoreSourceList({}).then((res: any) => {
                        const targetArr: any = [];
                        res.forEach((item: any) => {
                            targetArr.push(item);
                        });
                        resolve(targetArr);
                    });
                });
            },
            formatOption: (v: any) => ({
                label: v.name,
                value: v.id
            })
        },
        {
            label: '店铺信息',
            name: 'shop_info',
            value: '',
            type: 'input',
            placeholder: '请输入店铺名称｜店铺ID搜索'
        }
    ];
});

const tableOption = [
    {
        prop: 'retail_shop_id',
        label: '客易达店铺ID',
        width: 160,
        render({ row }: any) {
            return row?.retail_shop_id ? row?.retail_shop_id : '--';
        }
    },
    {
        prop: 'shop_ser_number',
        label: '店铺ID',
        width: 120,
        render({ row }: any) {
            return row?.shop_ser_number ? row?.shop_ser_number : '--';
        }
    },
    {
        prop: 'name',
        label: '店铺名称',
        width: 220,
        render({ row }: any) {
            return row?.name ? row?.name : '--';
        }
    },
    {
        prop: 'source_name',
        label: '店铺类型',
        width: 220,
        render({ row }: any) {
            const { source_logo, source_name } = row;
            return (
                <div class="store_state" style="display: flex;align-items: center;">
                    <img v-show={source_logo} style="width: 18px;height: 18px;" src={source_logo} alt="" />
                    <div class="state_text" style="margin: 0 4px;">
                        {source_name}
                    </div>
                </div>
            );
        }
    },
    {
        prop: 'state',
        label: '状态',
        width: 200,
        render({ row }: any) {
            // state  1-正常  2-异常停止  3-暂停  4 未开通
            const { state, state_name, remark, shop_abnormal_msg } = row;
            return (
                <div class="store_state" style="display: flex;align-items: center;">
                    <div
                        class="state_label"
                        style={`width: 10px;height: 10px;border-radius: 50%;background-color: ${
                            state == 1
                                ? '#2FB6E4'
                                : state == 2
                                ? '#FF4A1A'
                                : state == 3
                                ? '#FFD500'
                                : state == 4
                                ? '#D8D8D8'
                                : '#fff'
                        };`}></div>
                    <div class="state_text" style="margin: 0 4px;">
                        {state_name}
                        <span v-show={shop_abnormal_msg} style="color:red ">
                            （{shop_abnormal_msg}）
                        </span>
                    </div>
                    <el-tooltip v-show={state == 2} content={remark} effect="light" placement="top">
                        <img v-show={state == 2} style="width: 20px;height: 20px;" src="/static/err_tips.png" alt="" />
                    </el-tooltip>
                </div>
            );
        }
    },
    {
        prop: 'validity_start',
        label: '推广活动',
        width: 160,
        render({ row }: any) {
            const { source, is_open_promotion, promotion_type } = row;
            const sourceMap = [3, 6];
            if (is_open_promotion == 2 && sourceMap.includes(source)) {
                return (
                    <div>
                        {promotion_type.map((v: { id: string | number }) => {
                            return <div>已开启（{PROMOTION_ACTIVITY[v.id]}）</div>;
                        })}
                    </div>
                );
            } else if (is_open_promotion == 1 && sourceMap.includes(source)) {
                return '未开启';
            } else {
                return '--';
            }
        }
    },
    {
        prop: 'sync_type_name',
        label: '同步方式',
        width: 100,
        renderHeader({ row, index }: any) {
            return <tableHeaderTooltip title="同步方式" content={sync_type_tips.value} />;
        }
    },
    {
        prop: 'is_cert_name',
        label: '授权信息',
        width: 240,
        render({ row }: any) {
            // is_cert 0-无 1-是 2-否
            const { name, auth_info, is_cert, is_cert_name, source_logo } = row;
            if (is_cert == 0) {
                return '--';
            } else {
                return (
                    <>
                        <div style="display: flex;align-items: center;margin-bottom: 4px;">
                            <img v-show={source_logo} style="width: 20px;height: 20px;" src={source_logo} alt="" />
                            <div class="state_text" style="margin: 0 6px;font-size:12px;">
                                {name || '--'}
                            </div>
                        </div>
                        <div style="display: flex;align-items: center;">
                            <img
                                style="width: 18px;height: 18px;"
                                src={`/static/${is_cert == 1 ? 'is_certed' : ''}.png`}
                                alt=""
                            />
                            <div style="margin-right: 6px;color: #60B900;font-size:12px;">{is_cert_name || '--'}</div>
                        </div>
                    </>
                );
            }
        }
    },
    {
        prop: 'hyt_status_name',
        label: '会员通状态',
        width: 120,
        showOverflowTooltip: true,
        renderHeader() {
            const content = [
                { text: '会员通：开通了全渠道会员打通服务，为入会会员实现积分计算、等级计算、会员权益等功能。' }
            ];
            return <tableHeaderTooltip title="会员通状态" content={content} />;
        }
    },
    {
        prop: 'created_name',
        label: '创建人',
        width: 120,
        render({ row }: any) {
            return row?.created_name ? row?.created_name : '--';
        }
    },
    {
        prop: 'created_at',
        label: '创建时间',
        minWidth: 200
    },
    {
        prop: 'operate',
        label: '操作',
        width: 220,
        fixed: 'right',
        isOperate: true,
        renderOperate({ row }: any) {
            return (
                <>
                    <ElButton
                        size="small"
                        onClick={() => {
                            const { id: shop_id } = row;
                            const state = row.state == 1 ? 3 : 1;
                            const params = { shop_id, state };
                            updateStoreState(params).then(() => {
                                ElMessage.success(`${row.state == 1 ? '暂停成功' : '运行成功'}`);
                                storeTableRef.value?.reload?.();
                            });
                        }}>
                        {row.state == 1 ? '暂停' : '运行'}
                    </ElButton>
                    <ElButton
                        //淘宝天猫类型线路一不允许编辑
                        disabled={(row.source == 3 || row.source == 6) && row.sync_line == '1c8aa0614e8f195b'}
                        size="small"
                        onClick={() => {
                            const { id: shop_id, name, source, state, retail_shop_id } = row;
                            // 1 客易达   2 有赞   3 淘宝   4 自营   5 线下门店   6 天猫   7 抖店   8 京东 10 快手小店
                            switch (source) {
                                case 3:
                                    router.push(
                                        `/ecommerce/storeManage/list/addTaoBaoStore?source=${source}&shop_id=${shop_id}&state=${state}&type=edit&retail_shop_id=${retail_shop_id}`
                                    );
                                    break;
                                case 6:
                                    router.push(
                                        `/ecommerce/storeManage/list/addTmallStore?source=${source}&shop_id=${shop_id}&state=${state}&type=edit&retail_shop_id=${retail_shop_id}`
                                    );
                                    break;
                                case 7:
                                    router.push(
                                        `/ecommerce/storeManage/list/addDouYinStore?source=${source}&shop_id=${shop_id}&state=${state}&type=edit&retail_shop_id=${retail_shop_id}`
                                    );
                                    break;
                                case 10:
                                    router.push(
                                        `/ecommerce/storeManage/list/addKuaiShouStore?source=${source}&shop_id=${shop_id}&state=${state}&type=edit&retail_shop_id=${retail_shop_id}`
                                    );
                                    break;
                                default:
                                    editStoreForm.shop_id = shop_id;
                                    editStoreForm.name = name;
                                    editStoreForm.source = source;
                                    appDialogEditStore.visible = true;
                                    break;
                            }
                        }}>
                        编辑
                    </ElButton>

                    <ElButton
                        // 1 客易达   2 有赞   3 淘宝   4 自营   5 线下门店   6 天猫   7 抖店   8 京东
                        // state  4  店铺未开通
                        v-show={
                            ([3, 6].includes(row.source) && row.state == 4) ||
                            ([7].includes(row.source) && row.sync_type == 1)
                        }
                        size="small"
                        onClick={() => {
                            changePackage.value = true;
                        }}>
                        联系客服开通
                    </ElButton>
                    <ElButton
                        v-show={row.source == 1 && !!row.subscribe_url}
                        size="small"
                        onClick={() => {
                            const { id: shop_id } = row;
                            const params = { shop_id };
                            testStore(params).then(() => {
                                ElMessage.success('测试成功');
                                storeTableRef.value?.reload?.();
                            });
                        }}>
                        测试
                    </ElButton>
                    <ElButton
                        size="small"
                        onClick={() => {
                            const { id: shop_id, name, logo, source, source_name, retail_shop_id } = row;
                            // source  1 客易达   2 有赞   3 淘宝   4 自营   5 线下门店   6 天猫   7 抖店   8 京东 9 视频号小店 10 快手小店
                            const params = `shop_id=${encodeURIComponent(shop_id)}&name=${encodeURIComponent(
                                name
                            )}&source_name=${encodeURIComponent(source_name)}&source=${encodeURIComponent(
                                source
                            )}&logo=${encodeURIComponent(logo)}&retail_shop_id=${encodeURIComponent(retail_shop_id)}`;
                            const path = `/ecommerce/storeManage/list/storeDetail?${params}`;
                            router.push(path);
                        }}>
                        数据
                    </ElButton>
                    <ElButton
                        v-show={row.is_hyt === 2} // 1否 2是 是否展示会员通按钮
                        size="small"
                        onClick={() => {
                            handleOpenMemberPass(row);
                        }}>
                        启用会员通
                    </ElButton>
                    <ElButton
                        v-show={row.is_hyt_upgrade == 2} //是否展示升级会员通按钮
                        size="small"
                        onClick={() => {
                            handleUpgradeYouZan(row);
                        }}>
                        升级会员通
                    </ElButton>
                    <ElButton
                        v-show={row.is_hyt_set == 2} // 是否展示调整会员通按钮
                        size="small"
                        onClick={() => {
                            handleAdjustMemberPass(row);
                        }}>
                        调整会员通设置
                    </ElButton>
                    <ElButton
                        v-show={false}
                        size="small"
                        onClick={() => {
                            // 8.4 淘天合作方案去除删除店铺功能
                            const { id: deleteId } = row;
                            state.deleteId = deleteId;
                            appDialogDeleteStore.visible = true;
                        }}>
                        删除
                    </ElButton>
                    <ElButton
                        //天猫淘宝类型未初始化数据展示数据初始化按钮
                        //3淘宝6天猫service_application选择应用服务并且is_open_virtual打开虚拟号async_task_id为0未初始化
                        v-show={
                            row.async_task_id == 0 &&
                            (row.source == 3 || row.source == 6) &&
                            row.service_application == 1 &&
                            row.is_open_virtual == 1 &&
                            row.sync_line != '1c8aa0614e8f195b'
                        }
                        size="small"
                        onClick={e => initData(row.id, e)}>
                        数据初始化
                    </ElButton>
                    <ElButton
                        //天猫淘宝类型初始化数据后展示数据初始化按钮
                        //3淘宝6天猫service_application选择应用服务并且is_open_virtual打开虚拟号async_task_id大于0已初始化展示查看初始化进度
                        v-show={
                            row.async_task_id > 0 &&
                            (row.source == 3 || row.source == 6) &&
                            row.service_application == 1 &&
                            row.is_open_virtual == 1 &&
                            row.sync_line != '1c8aa0614e8f195b'
                        }
                        size="small"
                        onClick={() => {
                            router.push('/channelconfig/dataManagement/asyncTask');
                        }}>
                        查看初始化进度
                    </ElButton>
                    <ElButton
                        //增加查看功能
                        v-show={[1, 2, 3, 4, 5, 6, 7, 9, 10].includes(row.source)}
                        size="small"
                        onClick={() => {
                            const { id: shop_id, name, source, state, retail_shop_id } = row;
                            // source: 1 客易达   2 有赞   3 淘宝   4 自营   5 线下门店   6 天猫   7 抖店   8 京东  9 视频号 10 快手小店
                            switch (source) {
                                case 1:
                                    router.push(
                                        `/ecommerce/storeManage/list/addKeyidaStore?source=${source}&shop_id=${shop_id}&state=${state}&type=look&retail_shop_id=${retail_shop_id}`
                                    );
                                    break;
                                case 2:
                                    router.push(
                                        `/ecommerce/storeManage/list/addYouzanStore?source=${source}&shop_id=${shop_id}&state=${state}&type=look&retail_shop_id=${retail_shop_id}`
                                    );
                                    break;
                                case 3:
                                    router.push(
                                        `/ecommerce/storeManage/list/addTaoBaoStore?source=${source}&shop_id=${shop_id}&state=${state}&type=look&retail_shop_id=${retail_shop_id}`
                                    );
                                    break;
                                case 4:
                                    router.push(
                                        `/ecommerce/storeManage/list/addSelfStore?source=${source}&shop_id=${shop_id}&state=${state}&type=look&retail_shop_id=${retail_shop_id}`
                                    );
                                    break;
                                case 5:
                                    router.push(
                                        `/ecommerce/storeManage/list/addOfflineStore?source=${source}&shop_id=${shop_id}&state=${state}&type=look&retail_shop_id=${retail_shop_id}`
                                    );
                                    break;
                                case 6:
                                    router.push(
                                        `/ecommerce/storeManage/list/addTmallStore?source=${source}&shop_id=${shop_id}&state=${state}&type=look&retail_shop_id=${retail_shop_id}`
                                    );
                                    break;
                                case 7:
                                    router.push(
                                        `/ecommerce/storeManage/list/addDouYinStore?source=${source}&shop_id=${shop_id}&state=${state}&type=look&retail_shop_id=${retail_shop_id}`
                                    );
                                    break;
                                case 9:
                                    router.push(
                                        `/ecommerce/storeManage/list/addVideoNumberStore?source=${source}&shop_id=${shop_id}&state=${state}&type=look&retail_shop_id=${retail_shop_id}`
                                    );
                                    break;
                                case 10:
                                    router.push(
                                        `/ecommerce/storeManage/list/addKuaiShouStore?source=${source}&shop_id=${shop_id}&state=${state}&type=look&retail_shop_id=${retail_shop_id}`
                                    );
                            }
                        }}>
                        查看
                    </ElButton>
                </>
            );
        }
    }
];
/* ----------------------------调整会员通弹框 of start------------------------ */
const adjustDialog = ref(false); //是否展示调整会员通弹框
const member_rule_follow = ref('1'); //会员通配置
const memberRules = ref([]); // 会员通渠道列表（积分规则列表）
const shopId = ref(''); // 店铺ID
// 打开调整会员通弹框
const handleAdjustMemberPass = (row: any) => {
    getChannelByShopId({ shop_id: row.id }).then((res: any) => {
        memberRules.value = res;
        member_rule_follow.value = res.find((v: any) => v.point_rule_is_select == 1).id || res[0]?.id; // 默认选择
        shopId.value = row.id;
        adjustDialog.value = true;
    });
};
// 调整会员通弹框确认事件
const handleConfirmAdjustMemberPass = async () => {
    try {
        const res = await memberSwitchChannel({
            shop_id: shopId.value,
            member_rule_follow:
                memberRules.value.find((v: any) => v.id == member_rule_follow.value).hyt_points_type || ''
        });
        if (res) {
            ElMessage.success('操作成功');
        }
        adjustDialog.value = false;
    } catch (error) {
        adjustDialog.value = false;
    }
    storeTableRef.value?.reload();
};
/**
 * 打开积分设置页面
 */
const handleOpenIntegral = () => {
    window.open(`${location.origin}/member/pointsManage/pointsSettings`);
};
/* ----------------------------调整会员通弹框 of end--------------------------- */
/* ----------------------------升级会员通 of start------------------------ */
const handleUpgradeYouZan = (row: any) => {
    router.push(
        `/ecommerce/storeManage/list/upgradeYouZanMemberPass?upgrade=1&shop_id=${row.id}&hyt_type=${row.hyt_type}`
    );
};
/* ----------------------------升级会员通 of end--------------------------- */
/* ----------------------------启用会员通-start---------------------------- */
const openMemberPassRef = ref(null); // 会员通弹窗ref实例
// 打开会员通弹窗--启用
const handleOpenMemberPass = (row: any) => {
    openMemberPassRef.value?.open(row);
};
// 启用成功后刷新列表
const onMemberPassSubmit = () => {
    storeTableRef.value?.reload();
};
/* ----------------------------启用会员通-end---------------------------- */

//数据初始化
const initData = (val: any, e: any) => {
    shopDateInit({ retail_shop_id: val, task_module: 30 }).then(() => {
        parabolaAnimation(e);
        ShowTaskMessage('数据初始化异步任务创建成功');
        reset();
    });
};
const cancelHandel = (): void => {
    appDialogEditStore.visible = false;
    editStoreForm.shop_id = '';
    editStoreForm.name = '';
    editStoreForm.source = '';
};
const submitHandel = async () => {
    if (!editStoreFormRef.value) return;
    await editStoreFormRef.value.validate((valid: any): void => {
        if (valid) {
            editStore(editStoreForm).then(() => {
                ElMessage.success('编辑成功');
                cancelHandel();
                storeTableRef.value?.reload?.();
            });
        }
    });
};

const appDialogEditStore = reactive<any>({
    visible: false,
    title: '编辑店铺',
    width: '500px',
    cancel: cancelHandel,
    submit: submitHandel,
    cancelText: '取消',
    submitText: '保存'
});

const cancelHandelDelete = (): void => {
    appDialogDeleteStore.visible = false;
    state.deleteId = '';
};
const submitHandelDelete = async () => {
    deleteStore({ shop_id: state.deleteId }).then(() => {
        ElMessage.success('删除成功');
        cancelHandelDelete();
        storeTableRef.value?.reload?.();
    });
};
const appDialogDeleteStore = reactive<any>({
    visible: false,
    title: '删除店铺',
    width: '500px',
    cancel: cancelHandelDelete,
    submit: submitHandelDelete,
    cancelText: '取消',
    submitText: '确定'
});

const search = (data: any): void => {
    const { source, shop_info } = data;
    data = Object.assign({}, data, { source: source || 0, shop_info: shop_info || '' });
    state.searchParams = data;
    currentParams.value = data;
};
const reset = (): void => {
    state.searchParams = lodash.cloneDeep(defaultParams);
    currentParams.value = null;
};
/**
 * @description: 展开收起
 */
const expandHandle = (expand: boolean) => {
    state.searchHeight = expand ? '112px' : '64px';
};
const fetchApi = (): any => {
    return new Promise((resolve: any): any => {
        const page_size: string | number = 15;
        const params = {};
        resolve([params, getStoreList]);
    });
};
const addStore = () => {
    isShowSelectStore.value = true;
};

const getStoreSyncData = async () => {
    const res = await getStoreSync({});
    if (res?.is_open_application == 0) {
        // 是否开通：0未开通，1开通
        introduce_url.value = res?.introduce_url || '';
        isDataDefault.value = true;
    } else {
        isDataDefault.value = false;
    }
};

onMounted(async () => {
    await getStoreSyncData();
});

onActivated(async (val: any) => {
    await getStoreSyncData();
    state.searchParams = { ...deepCopy(defaultParams), ...currentParams.value };
});
</script>

<style lang="scss" scoped>
.store_message_list_container {
    height: calc(100vh - 142px);
    padding: 24px;
    border: 1px solid #eaeaea;
    border-radius: 4px;
    box-sizing: border-box;
    background-color: #fff;
    display: flex;
    flex-direction: column;
    overflow: hidden;

    .zw-table {
        display: flex;
        flex-direction: column;
        flex: 1;
        overflow: hidden;

        :deep(.el-table) {
            flex: 1;

            .el-table__empty-block {
                position: absolute;
                top: 50%;
                left: 50%;
                transform: translate(-50%, -50%);
            }
        }
    }
}

.tips {
    line-height: 2;
    font-size: 13px;
    color: #555;
    font-weight: 300;
    letter-spacing: 1px;
}

.store_state {
    display: flex;
    align-items: center;

    .state_label {
        width: 16px;
        height: 16px;
        border-radius: 50%;
        background-color: #2fb6e4;
    }

    .state_text {
        margin-left: 4px;
    }
}

// 调整会员通弹框 of start
.adjust_dialog_content {
    height: 64px;
    background: #fffaf9;
    border-radius: 4px;
    padding: 12px 16px;
    font-size: 14px;
    font-family: PingFangSC-Regular, 'PingFang SC';
    font-weight: 400;
    color: #33302d;
    line-height: 20px;
    box-sizing: border-box;

    span {
        color: #ff6b00;
        cursor: pointer;
    }
}

// 调整会员通弹框 of end
</style>
